package felix.dataviewer.View;

import android.view.View;
import android.widget.ExpandableListView;

import java.util.ArrayList;
import java.util.List;

import felix.dataviewer.Base.PresenterFactory;
import felix.dataviewer.Data.AppBean;
import felix.dataviewer.Presenter.AppPresenter;
import felix.dataviewer.R;
import felix.dataviewer.adp.AppEAdp;
import felix.felixlib.Base.BaseFg;
import felix.felixlib.Base.adp.AdpFactory;
import felix.felixlib.annotation.BindLayout;
import felix.felixlib.annotation.BindView;

/**
 * Created by huangmf on 7/28/2017.
 */
@BindLayout(R.layout.fg_main)
public class MainFg extends BaseFg implements AppPresenter.AppViewI {
    @BindView(R.id.elv_app)
    ExpandableListView mElvApp;
    private AppEAdp mAppEAdp;
    private List<AppBean> mAppBeen;
    private AppPresenter mAppPresenter;

    @Override
    protected void initData(View view) {
        super.initData(view);
        mAppPresenter = PresenterFactory.createPresenter(AppPresenter.class, mContext, this);
        mAppBeen = new ArrayList<>();
        mAppEAdp = AdpFactory.createEADP(AppEAdp.class, mContext, mAppBeen);
        mElvApp.setAdapter(mAppEAdp);
        mAppPresenter.loadApp();
    }

    @Override
    public void loadApp(List<AppBean> appBeen) {
        mAppBeen.clear();
        mAppBeen.addAll(appBeen);
        mAppEAdp.notifyDataSetChanged();
    }
}
